#include "evos_time_schedule.h"
#include "my_led.h"
#include "eventos.h"
#include "event_def.h"
/* data structure ----------------------------------------------------------- */
typedef struct eos_reactor_time_tag {
    eos_reactor_t super;

    eos_u8_t status;
} eos_reactor_time_t;

eos_reactor_time_t actor_time;

/* static event handler ----------------------------------------------------- */
static void time_e_handler(eos_reactor_time_t * const me, eos_event_t const * const e);

/* api ---------------------------------------------------- */
void eos_reactor_time_init(void)
{
    eos_reactor_init(&actor_time.super, 2, EOS_NULL);
    eos_reactor_start(&actor_time.super, EOS_HANDLER_CAST(time_e_handler));

    actor_time.status = 0;

#if (EOS_USE_PUB_SUB != 0)
    eos_event_sub((eos_actor_t *)(&actor_time), Event_Time_1000ms);
#endif
#if (EOS_USE_TIME_EVENT != 0)
    eos_event_pub_period(Event_Time_1000ms, 1000);
#endif
}

/* static state function ---------------------------------------------------- */
static void time_e_handler(eos_reactor_time_t * const me, eos_event_t const * const e)
{
   switch (e->topic)
   {
   case Event_Time_1000ms:
    /* code */
    LED_TOGGLE;
    break;
   default:
    break;
   }
}


